package compiler;

import graph.Graph;

import java.io.IOException;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;

/**
 * A compiler which compiles the properties file specified in the properties grammar
 * and generates the corresponding parse tree.
 *
 */

public class PropertiesCompiler {
	
	/**
	 * 
	 * @param file The properties file to compile
	 * @return The corresponding graph
	 * @throws IOException 
	 * @throws RecognitionException 
	 */
	public Graph getGraph(String file) throws IOException, RecognitionException
	{
		ANTLRFileStream input = new ANTLRFileStream(file);
		propLexer lexer = new propLexer(input);
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		propParser parser = new propParser(tokens);
		Graph graph = parser.program();
		
		return graph;
		
	}
}
